package com.hnichr.ump.talent.library.service.impl;

import com.hnichr.ump.common.talent.library.entity.PersonalInfo;
import com.hnichr.ump.common.talent.library.service.PersonalInfoService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PersonalInfoServiceImpl extends BaseServiceImpl<PersonalInfo> implements PersonalInfoService {

    private static final Logger logger = LoggerFactory.getLogger(PersonalInfoServiceImpl.class);

    @Override
    @Transactional(readOnly = true)
    public PersonalInfo getByUserId(String userId) {
        List<PersonalInfo> personalInfoList = JpaUtil.linq(PersonalInfo.class).equal("userId",userId).list();
        if(CollectionUtils.isNotEmpty(personalInfoList)){
            return personalInfoList.get(0);
        }
        return null;
    }
    @Override
    @Transactional(readOnly = true)
    public List<PersonalInfo> getBySyncDate(String syncDate){
        return JpaUtil.linq(PersonalInfo.class).equal("syncDate",syncDate).list();
    }
}
